package com.china08.yxyapi.api.home.activity.healthcompetition;

import java.time.LocalDate;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.model.YxyApiRespModel;

@RestController
@CrossOrigin
public class DateLimit {

    @RequestMapping(value = "/api_yw/h5/activity/healthcompetition/date", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel process() {
        RespModel respModel = new RespModel();

        LocalDate now = LocalDate.now();

        // 开始时间
        LocalDate startDate = LocalDate.of(2017, 12, 28);
        // 结束时间
        LocalDate endDate = LocalDate.of(2018, 3, 28);

        if (now.isBefore(startDate)) {
            respModel.status = 0;
        } else if (now.isAfter(endDate)) {
            respModel.status = 2;
        } else {
            respModel.status = 1;
        }
        return respModel;
    }

    protected static class RespModel extends YxyApiRespModel {
        // 是否完成答题：0 1 2
        public Integer status;
    }

}
